If you want to completely disable IPv6 on your Ubuntu Linux system, then you need to make some changes to Linux kernel parameter.
Edit the 99-sysctl.conf file.
sudo nano /etc/sysctl.d/99-sysctl.conf
Copy and paste the following 3 lines at the bottom of the file.
net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1
Save and close the file. Then execute the following command to load the above changes.
sudo sysctl -p
Now run the following command. You should see 1, which means IPv6 has been successfully disabled.
cat /proc/sys/net/ipv6/conf/all/disable_ipv6

Parameters defined in 99-sysctl.conf file is preserved across reboot, so IPv6 won’t be enabled next time you boot up Ubuntu unless you manually re-enable it.
To re-enable IPv6 on Ubuntu, simply remove those 3 lines in 99-sysctl.conf file and run sudo sysctl -p command to load the changes.